define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'admin/order/index?activity_id=' + window.activityId,
        export_url: 'admin/order/export?activity_id=' + window.activityId
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh', 'export'],
                cols: [[
                    {field: 'a.pay_no', title: '支付编号', hide: true},
                    {field: 'b.nickname', title: '昵称', hide: true},
                    {field: 'a.name', title: '姓名', hide: true},
                    {field: 'a.phone', title: '手机号', hide: true},

                    {field: 'pay_no', title: '支付编号', search: false},
                    {field: 'total_price', title: '收款金额', search: false},
                    {field: 'nickname', title: '昵称', search: false},
                    {field: 'name', title: '姓名', search: false},
                    {field: 'phone', title: '手机号', search: false},
                    {field: 'customer_type', title: '新客/老客', search: false},
                    {field: 'is_clerk_recom', title: '员工直推/非直推', search: false, templet: function (d) {
                        if (d.is_clerk_recom === 1) {
                            return '员工直推';
                        } else {
                            return '非直推';
                        }
                    }},
                    {field: 'openid', title: 'openid', search: false},
                    {field: 'activity_title', title: '所属活动', search: false},
                    {field: 'pay_time', title: '收款时间', search: false},
                    {width: 250, title: '操作', templet: "#buttonTpl"},
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };

    return Controller;
});